#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=4e5+5;
int n,a[N],s[N],cnt,ans;
map<int,int>Map;
void solve()
{
	int L=1,R=0;
	for(int i=1;i<=cnt;i++)
	{
		int l=s[i],r=s[cnt]-s[cnt-i];
		if(i==1||R<l)
		{
			ans+=max(0ll,R-L);
//			cout<<"??: "<<L<<' '<<R<<'\n';
			L=l,R=r;
		}
		else R=max(R,r);
	}
}
void work()
{
	cnt=ans=0;
	int x;
	cin>>x;
	if(!Map[x])Map[x]=1;
	else Map[x]=0;
	for(auto t:Map)
	{
		if(!t.second)continue;
		a[++cnt]=t.first;
	}
	sort(a+1,a+1+cnt);
	for(int i=1;i<=cnt;i++)s[i]=s[i-1]+a[i];
	solve();
	cout<<ans<<'\n';
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	freopen("kte.in","r",stdin);
	freopen("kte.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)work();
	return 0;
}
/*
6
2
4
1
5
3
4
*/
